package chapter4.No4_1_使用reentrantLock类.demo4;

import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.ReentrantLock;

/**
 * !
 *
 * @author liujian
 * @version 2016/11/21 0021
 */
public class ServiceClass {
    ReentrantLock lock = new ReentrantLock();
    Condition condition = lock.newCondition();

    public void methodA() {
        try {
            lock.lock();
            System.out.println("线程开始执行");
            condition.await();
            System.out.println("线程结束执行");
        } catch (InterruptedException e) {
            e.printStackTrace();
        }finally {
            lock.unlock();
        }
    }

}
